from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

def recog(single_query):
    label2id = {'nonmed': "0", 'med': "1"}  # 0:闲聊, 1: 问诊
    MODEL_NAME = '/changzheng/PracticalTraining/lyj/lingdongai/models/intent_recog_model/stevenzhun/RoBERTa-Chinese-Med-Inquiry-Intention-Recognition-base'

    recognizer = pipeline(task=Tasks.text_classification, model=MODEL_NAME)

    outputs = recognizer(single_query)
    single_intention = label2id[outputs.get('labels')[0]]
    print("意图识别为: ", single_intention)
    return single_intention